<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#-- 包含其他文件的内容 -->
    <#include "../common/header.ftl"/>
    <script src="/js/plugins/jqueryForm/jquery.form.js"></script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#-- 往数据模型中填充一个属性 -->
            <#assign menu="travel"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">注册用户管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <select name="state" class="form-control" >
                    <option value="1">待审核</option>
                    <option value="-1">已拒绝</option>
                </select>
                <input type="submit" value="查询">
            </form>
            <script>
                $("#searchForm select[name='state']").val(${qo.state});
            </script>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>状态</th>
                    <th></th>
                </tr>

            <#-- 循环迭代指令 -->
                <#list pageInfo.list as entity>
                    <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.title!}</td>
                       <td><img src="${entity.coverUrl!}" width="30px"> </td>
                       <td>${(entity.place.id)!}</td>
                       <td>${(entity.author.nickName)!}</td>
                       <td>${entity.stateName!}</td>
                        <td>
                            <button class="stateBtn" data-tid="${entity.id}" data-state="2" data-author="${entity.author.id}">发布</button>
                            <button class="stateBtn" data-tid="${entity.id}" data-state="-1" data-author="${entity.author.id}">拒绝</button>
                            <button class="showTravel"  data-tid="${entity.id}">查看文章</button>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<div class="modal fade" id="traveModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">文章内容</h4>
            </div>
            <div class="modal-body" id="modalBody">

            </div>
            <div class="modal-footer">

            </div>
        </div>
    </div>

</div>
<style>
    #traveModal img{
        width: 100%;
    }
</style>

<script>
    //发布拒绝按钮
    $(".stateBtn").click(function () {
        var id =$(this).data("tid");
        var state =$(this).data("state");
        var author =$(this).data("author");
        $.get("/travel/updateState.do",{id:id,state:state,"author.id":author},function (data) {
            if (data.success) {
                reload();
            }else{
                $.messager.alert(data.msg);
            }
        })
    })
    //查看文章
    $(".showTravel").click(function () {
        var id =$(this).data("tid");
        $.get("/travel/selectContentByTravelId.do",{id:id},function (data) {
            console.log(data.content);
            $("#modalBody").html(data.content);
            console.log($("#modalBody"));

            $("#traveModal").modal("show")
        })
    })

</script>

</body>
</html>